package com.ly.share.juc.statistics;

import java.util.function.Supplier;

/**
 * @author icanci
 * @since 1.0 Created in 2022/06/06 21:17
 */
public abstract class AbstractLockDemo {
    // 1千万
    protected static final int count = 1000 * 10000;

    protected static int       num   = 0;

    /**
     * log
     */
    protected <T> T log(Supplier<T> supplier) {
        long start = System.currentTimeMillis();
        T t = supplier.get();
        long end = System.currentTimeMillis();
        System.out.println(getClass().getName() + ": " + (end - start) + "ms");
        return t;
    }

    /**
     * log
     */
    protected static <T> T staticLog(Supplier<T> supplier, String name) {
        long start = System.currentTimeMillis();
        T t = supplier.get();
        long end = System.currentTimeMillis();
        System.out.println(name + " 执行了:" + (end - start) + "ms");
        return t;
    }
}
